package com.agricultural.robot.model;

/**
 * 农田模型
 */
public class Field {
    private String name;
    private double area; // 面积(公顷)
    private String soilType;
    private String[] obstacles;

    public Field(String name, double area, String soilType) {
        this.name = name;
        this.area = area;
        this.soilType = soilType;
        this.obstacles = new String[0];
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getArea() {
        return area;
    }

    public void setArea(double area) {
        this.area = area;
    }

    public String getSoilType() {
        return soilType;
    }

    public void setSoilType(String soilType) {
        this.soilType = soilType;
    }

    public String[] getObstacles() {
        return obstacles;
    }

    public void setObstacles(String[] obstacles) {
        this.obstacles = obstacles;
    }

    public void addObstacle(String obstacle) {
        String[] newObstacles = new String[obstacles.length + 1];
        System.arraycopy(obstacles, 0, newObstacles, 0, obstacles.length);
        newObstacles[obstacles.length] = obstacle;
        obstacles = newObstacles;
    }

    public boolean hasObstacle(String point) {
        for (String obstacle : obstacles) {
            if (obstacle.equals(point)) {
                return true;
            }
        }
        return false;
    }
}
